home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
msdos
/
plotting
/
pcgplots
/
gpt.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-24
|
9KB
|
356 lines
#define IDM_ABOUT 108
#define IDM_SAVE 109
#define IDM_META 110
#define IDM_INDEX 111
#define IDM_ERRORS 112
/* #define IDM_PAGE_SEL 113 */
#define IDM_OPEN 118
#define IDM_OPENMETA 119
#define IDM_CLOSE 120
#define IDM_EXIT 121
#define IDM_FILEARG 122
#define IDM_NEXT 150
#define IDM_PREVIOUS 151
#define IDM_TILE 152
#define IDM_CASCADE 153
#define IDM_ARRANGE 154
#define IDM_CLOSEALL 155
#define IDM_FIRSTCHILD 200
#define IDD_MESS 139
#define IDD_MESS2 140
#define IDD_FNAME 141
#define IDD_PNUM 142
#define IDD_FPATH 143
#define IDD_FLIST 144
#define IDD_PLIST 145
#define IDD_SELECT 147
/* following is not included in .rc files */
#ifdef __BCPLUSPLUS__
#include <windows.h>
#include <stdlib.h>
#include <string.h>
const INIT_MENU_POS = 0;
const CGM_MENU_POS = 5;
const WMETA_MENU_POS = 2;
const CREATE_POP = 2;
#define NO_PAGE_SELECTED 0
#include "gpta.h"
void HourGlass(HWND hWnd);
void OKMsgBox( char *szCaption, char *szFormat, ...);
BOOL OKCancelMsgBox( char *szCaption, char *szFormat, ...);
void SeparateFile(LPSTR lpDestPath, LPSTR lpDestFileName, LPSTR lpDestExt,
LPSTR lpSrcFileName);
LPSTR lstrchr (LPSTR str, char ch) ;
LPSTR lstrrchr (LPSTR str, char ch) ;
void ChangeDefExt(LPSTR Ext, LPSTR Name);
void AddExt(LPSTR Name, LPSTR Ext);
void ChangeExt(LPSTR Name, LPSTR Ext);
inline void DeleteSz(LPSTR Sz) { if (Sz) delete [] Sz; }
inline short max(short i1, short i2)
{
if (i1 > i2) return i1;
else return i2;
}
inline short min(short i1, short i2)
{
if (i1 < i2) return i1;
else return i2;
}
// If data pointers are near pointers
#if defined(__SMALL__) || defined(__MEDIUM__)
inline WindowPt GetPointer( HWND hWnd )
{ return (WindowPt) GetWindowWord( hWnd, 0 );}
inline void * GetObjectPt(DWORD lParam)
{ return (void *)LOWORD(lParam); }
inline void SetPointer( HWND hWnd, WindowPt pWindow )
{ SetWindowWord( hWnd, 0, (WORD) pWindow ); }
inline void SetObjectPt(void *FObj, DWORD *lParam)
{ *lParam = MAKELONG(FObj, 0); }
// else pointers are far
#elif defined(__LARGE__) || defined(__COMPACT__)
inline WindowPt GetPointer( HWND hWnd )
{ return (WindowPt) GetWindowLong( hWnd, 0 );}
inline void *GetObjectPt(DWORD lParam)
{ return (void *)lParam; }
inline void SetPointer( HWND hWnd, WindowPt pWindow )
{ SetWindowLong( hWnd, 0, (LONG) pWindow ); }
inline void SetObjectPt(void *FObj, DWORD *lParam)
{ *lParam = (DWORD)FObj;}
#else
#error Choose another memory model!
#endif
long FAR PASCAL _export WndProc( HWND hWnd, WORD iMessage,
WORD wParam, LONG lParam );
long FAR PASCAL _export gptWndProc( HWND hWnd, WORD iMessage,
WORD wParam, LONG lParam );
// ************************** Window class ************************
// *** class Window - Abstract Base Window class
class Window
{
private:
protected:
HWND hWndThis;
WORD iMessage;
WORD wParam;
LONG lParam;
public:
// Provide (read) access to the window's handle in case it is needed
// elsewhere.
HWND GetHandle( void ) { return hWndThis; }
WORD GetiMessage(void) {return iMessage; }
WORD GetwParam(void) {return wParam; }
LONG GetlParam(void) {return lParam; }
void DoCaption(LPSTR mess) { SetWindowText (hWndThis, (LPSTR)mess); }
BOOL Show( int nCmdShow ) { return ShowWindow( hWndThis, nCmdShow ); }
void Update( void ) { UpdateWindow( hWndThis ); }
// Pure virtual function makes Window an abstract class.
virtual long WndProc(HWND hwnd, WORD iMessage, WORD wParam,
LONG lParam) = 0;
virtual void Paint( void ) {}
virtual void Activate( void ) {}
virtual void Size( void ) {}
virtual void DeActivate( void ) {}
};
// **************** Scroller Class - Scroll Bar class
class Scroller
{
private:
HWND hWnd; // for Window which made Scroller obj
WindowPt win;
short nVscrollPos, nHscrollPos;
short MaxX, MaxY,ixMax, iyMax;
short ixMin, iyMin;
BOOL FullSize;
float XRatio;
float YRatio;
public:
void Scroll();
Scroller(WindowPt win,short xSBMax, short ySBMax);
short getnVscrollPos(void) { return nVscrollPos; }
short getnHscrollPos(void) { return nHscrollPos; }
void SetPos(short horz, short vert);
void SetXRatio( float ratio) { XRatio = ratio; }
void SetYRatio( float ratio) { YRatio = ratio; }
void NewSize(short x, short y);
BOOL IsFullSize( ) { return FullSize; }
};
// *********************** Application class *****************************
// *** class Appl - static application class
class Appl
{
public:
static HANDLE hInstance;
static HANDLE hPrevInstance;
static LPSTR CmdParam;
static int nCmdShow;
static HWND hWndClient;
static HWND hWndFrame;
static FrameWindowPt theFrame;
};
// ********** FrameWindow Class Declarations - Application's window
class FrameWindow : public Window
{
private:
static char FileName[128];
static char szClass[14];
static char szMenu[14];
static char szAccel[14];
HWND hWndClient;
FARPROC lpfnAboutDlgProc;
FARPROC lpfnCloseEnumProc;
static HMENU hMenu;
static HMENU hMenuWindow;
static HANDLE hAccel;
// Helper function used by Paint function; it is used as a
// callback function by LineDDA.
static BOOL FAR PASCAL AboutDlgProc( HWND hWnd, WORD message,
WORD wParam, LONG lParam);
static BOOL FAR PASCAL CloseEnumProc(HWND childhWnd, LONG lParam);
public:
// Register the class only AFTER WinMain assigns appropriate
// values to static members of Appl and only if no previous
// instances of the program exist (a previous instance would
// have already performed the registration).
static void Register( void );
void InitMenu();
static void LoadMenu( HANDLE hInstance);
static void LoadAccelerators( HANDLE hInstance);
int MessageLoop( void );
// FrameWindow Constructor - Do not create unless previously registered.
FrameWindow( void );
// *** FrameWindow destructor
~FrameWindow( void );
long WndProc( HWND hWnd, WORD iMessage, WORD wParam, LONG lParam );
void FrameWindow::GetDisplayCaps(void);
}; // end of FrameWindow class definition
// *** class CGMWindow
class CGMWindow : public Window
{
public:
HMENU hMenu; // myerror needs this
static HWND hWindow; //myerror needs this
LOGPALETTE *pPalette;
HPALETTE hPal;
private:
static char szClass[14];
static char szMenu[20];
HANDLE hmf;
HMENU hMenuWindow;
short cxClient, cyClient;
short cxMetaClient, cyMetaClient;
Scroller *SBars;
RECT DrawRect;
FileObjectPt FObj;
CgmObjectPt CgmObj;
void DoCaption( LPSTR mesg);
public:
int errors;
BOOL severe_error;
LPSTR ErrMsg1;
LPSTR ErrMsg2;
static void Register( void );
static void LoadMenu( HANDLE hInstance);
CGMWindow( FileObjectPt );
~CGMWindow( void );
long WndProc(HWND hWnd, WORD iMessage, WORD wParam, LONG lParam );
void Paint( void );
void Activate( void );
void Size( void );
void DeActivate( void );
}; // end of CGMWindow class
// *** class WMetaWindow
class WMetaWindow : public Window
{
private:
static HMENU hMenu;
static HMENU hMenuWindow;
static char szClass[14];
static char szMenu[20];
HANDLE hmf;
short cxClient, cyClient;
short cxMetaClient, cyMetaClient;
int MetaX;
int MetaY;
HBITMAP hCompBit;
HDC hMemDC;
HBITMAP hOldBit;
Scroller *SBars;
RECT DrawRect;
FileObjectPt FObj;
//CgmObjectPt CgmObj;
void DoCaption( LPSTR mesg);
public:
int errors;
BOOL severe_error;
LPSTR ErrMsg1;
LPSTR ErrMsg2;
static void Register( void );
static void LoadMenu( HANDLE hInstance);
static void FAR PASCAL LineFunc( int X, int Y, LPSTR lpData );
static int FAR PASCAL MetaEnum(HDC hDC, LPHANDLETABLE lpHTable,
LPMETARECORD lpMFR, int nObj,BYTE FAR * lpClientData);
WMetaWindow( FileObjectPt );
~WMetaWindow( void );
long WndProc(HWND hWnd, WORD iMessage, WORD wParam, LONG lParam );
void Paint( void );
void Activate( void );
void Size( void );
void DeActivate( void );
void SetExtents();
}; // end of WMetaWindow class
// *** class IndexObject
class IndexObject
{
public:
static IndexObjectPt ThisIndexObject;
private:
CgmObjectPt CgmObj;
WORD Page;
public:
~IndexObject( void ) { }
IndexObject( CgmObjectPt CgmObj ) {this->CgmObj = CgmObj; }
static BOOL FAR PASCAL IndexDlgProc (HWND hDlg, WORD message,
WORD wParam, LONG lParam);
void IndexCgm(HWND hWndParent);
WORD GetPage( void) { return Page; }
}; // End of class IndexObject
// *** class PageObject
class PageObject
{
public:
static PageObjectPt ThisPageObject;
private:
CgmObjectPt CgmObj;
WORD Page;
public:
~PageObject( void ) { }
PageObject( CgmObjectPt CgmObj ) {this->CgmObj = CgmObj; }
static BOOL FAR PASCAL PageDlgProc (HWND hDlg, WORD message,
WORD wParam, LONG lParam);
void PageCgm(HWND hWndParent);
WORD GetPage( void) { return Page; }
}; // End of class IndexObject
#endif